<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div id="officemanshow"></div>
</body>

<script type="text/javascript" src="../js/jquery-3.3.1.js" ></script>
<script type="text/javascript">
	
$(function() {

	$.ajax({
		type: "post",
		url: "showofficeman",
		async: true,

		success: function(result) {
			var msg = "<table border='1px'><tr><th>文员ID</th><th>姓名</th><th>年龄</th><th>性别</th><th>联系方式</th><th>职位</th><th>所属办公室</th><th>直属领导的</th><th>操作</th></tr>";
			$.each(result, function() {
				msg += "<tr><td>" + this.officemanId+"</td><td>"+this.officemanName+ "</td><td>"+this.officemanAge+ "</td><td>"+this.officemanSex+ "</td><td>"+this.officemanTelephone+ "</td><td>"+this.job+ "</td><td>"+this.officeName+ "</td><td>"+this.bossName+ "</td><td><button type='button' id='"+this.officemanId+"' onclick='del(id)'>删除</button></td>";
			});
			msg+="</table>";
			$("#officemanshow").append(msg);
		},

		error: function() {
			alert("error");
		}
	});

});


function del(id){
	$.ajax({
		type:"post",
		url:"deleteofficeman",
		async:true,
		data:'officemanId='+id,
		
		success:function(){
			var element=document.getElementById(id).parentNode.parentNode;
			element.parentNode.removeChild(element);
		},
		error:function(){
			alert("error");
		}
	});
}


</script>

</html>